/**
 * Sample React Native App
 * https://github.com/facebook/react-native
 * @flow
 */

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View
} from 'react-native';
/**
 *方式1 ：es6
 * 推荐
 */
export  default class LifecycleComponent extends Component {
	constructor(props){
		super(props)
		console.log('--------constructor')
		this.state ={
			count:0
		}

	}
	componentWillMount(){
		console.log('--------componentWillMount')
	}
	componentDidMount(){
		console.log('--------componentDidMount')	
	}
	componentWillReceiveProps(nextProps){
		console.log('--------componentWillReceiveProps')
	}
	shouldComponentUpdate(nextProps,nextState){
		console.log('--------shouldComponentUpdate',this.state.count)
		return true

	}
	componentWillUpdate(nextProps,nextState){
		console.log('--------componentWillUpdate',this.state.count)
	}
	componentDidUpdate(nextProps,nextState){
		console.log('--------componentDidUpdate',this.state.count)
	}
	componentWillUnmount(){
		console.log('--------componentWillUnmount')
	}

	render(){
		console.log('--------render',this.state.count)			
		return  <View>
					<Text style={{fontSize:20,backgroundColor:'red'}} 
						  onPress={()=>{
						  	console.log(this.state.count)
						  	this.setState({count:this.state.count+1})
						  	console.log(this.state.count)
						  }}	>
		 				 有本事你打我啊 组件的生命周期!
		 			</Text>
		 			<Text style={{fontSize:20}}>被打了{this.state.count}</Text>
				</View>
	}
}  

 